package tools;

import java.sql.*;

/**
 * @author :wnm
 * @program : 管家婆项目
 * @descript : JDBC
 * @create :2020-06-13 22:44
 */

public class JDBCUtils {

    public static Connection getConnection(String url)throws SQLException,ClassNotFoundException{
        Class.forName("com.mysql.jdbc.Driver");
        String uername="root";
        String userpassword="wn1723..+";
        Connection conn= DriverManager.getConnection(url,uername,userpassword);
        return conn;
    }


    public static void release(Statement stmt,Connection conn){
        if(stmt!=null){
            try{
                stmt.close();;
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (conn!=null){
            try{
                conn.close();
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    }
    public static void release(ResultSet rs,Connection con,Statement stmt){
        if(rs!=null){
            try{
                rs.close();
            }catch (Exception e){
                e.printStackTrace();
            }
            rs=null;
        }
        release(stmt,con);
    }
}
